import request from './request';

const api_vue = process.env.VUE_APP_API;

export const musicUrl = id => {
  return request({
    method: 'get',
    url: `${api_vue}/song/url?id=${id}&timestamp=${new Date().getTime()}`
  })
}

// 音乐是否可用
export const canPlay = id => {
  return request({
    method: 'get',
    url: `${api_vue}/check/music?id=${id}&timestamp=${new Date().getTime()}`
  })
}

// 获取视频分类标签
export const videoTags = () => {
  return request({
    method: 'get',
    url: `${api_vue}/video/category/list?timestamp=${new Date().getTime()}`
  })
}

// 获取视频所有分类标签
export const allVideoTags = () => {
  return request({
    method: 'get',
    url: `${api_vue}/video/group/list?timestamp=${new Date().getTime()}`
  })
}

// 获取全部视频
export const allVideo = offset => {
  return request({
    method: 'get',
    url: `${api_vue}/video/timeline/all?offset=${offset}&timestamp=${new Date().getTime()}`
  })
}

// 根据标签获取视频
export const videoGroup = (id, offset) => {
  return request({
    method: 'get',
    url: `${api_vue}/video/group?id=${id}&offset=${offset}&timestamp=${new Date().getTime()}`
  })
}

// 获取最新MV
export const newMv = params => {
  return request({
    method: 'get',
    url: `${api_vue}/mv/first`,
    params
  })
}

// 网易出品MV
export const rcmdMv = params => {
  return request({
    method: 'get',
    url: `${api_vue}/mv/exclusive/rcmd?timestamp=${new Date().getTime()}`,
    params
  })
}

// MV排行
export const topMv = params => {
  return request({
    method: 'get',
    url: `${api_vue}/top/mv`,
    params
  })
}

// 首页推荐MV
export const personalMv = () => {
  return request({
    method: 'get',
    url: `${api_vue}/personalized/mv?timestamp=${new Date().getTime()}`
  })
}

// 全部MV
export const allMV = params => {
  return request({
    method: 'get',
    url: `${api_vue}/mv/all`,
    params
  })
}

// 获取视频播放地址
export const videoPlayUrl = id => {
  return request({
    method: 'get',
    url: `${api_vue}/video/url?id=${id}&timestamp=${new Date().getTime()}`
  })
}

// 获取相关视频
export const relatedVideo = id => {
  return request({
    method: 'get',
    url: `${api_vue}/related/allvideo?id=${id}&timestamp=${new Date().getTime()}`
  })
}

// 获取视mv播放地址
export const mvPlayUrl = id => {
  return request({
    method: 'get',
    url: `${api_vue}/mv/url?id=${id}&timestamp=${new Date().getTime()}`
  })
}